package com.pic.mgt.syushin.converter;

import java.io.IOException;

import com.pic.mgt.monitor.WrongUnitFormatException;
import com.pic.mgt.monitor.parser.FormatParser;
import com.pic.mgt.syushin.unit.RealTargetOkSyushinMessageUnit;
import com.pic.mgt.unit.Unit;

public final class RealSyushinMessageUnitConverter extends
													SyushinMessageUnitConverter {
	private FormatParser messageTerminalIdParserForReal;
	
	private RealTargetOkSyushinMessageUnit realTargetOkSyushinMessageUnit;
	
	@Override
	protected void parseBusinessTypeContent(Unit unit) throws IOException,
			WrongUnitFormatException {
		this.realTargetOkSyushinMessageUnit = (RealTargetOkSyushinMessageUnit)
											   unit;
		
		doFill();
	}
	
	/*
	 * 放入業務型態內容資訊:
	 * (1) Terminal ID
	 */
	private void doFill() throws WrongUnitFormatException {
		// --------------------- (1) Terminal Id ---------------------
		// throws WrongUnitFormatException
		fillTerminalId();
	}
	
	private void fillTerminalId() throws WrongUnitFormatException  {
		this.realTargetOkSyushinMessageUnit.setTerminalId((String)
				this.messageTerminalIdParserForReal.parse(super.confirmationFile.getName()));
	}
	
	// --- getter and setter ---
	
	public void setMessageTerminalIdParserForReal(FormatParser messageTerminalIdParserForReal) {
		this.messageTerminalIdParserForReal = messageTerminalIdParserForReal;
	}
}
